package com.dkd.handler;

import cn.elegent.ac.ACHandler;
import cn.elegent.ac.annotation.Topic;
import com.dkd.config.TopicConfig;
import com.dkd.contract.VendoutContract;
import com.dkd.service.VendingMachineService;
import com.google.common.base.Strings;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * vendout味精处理程序
 *
 * @author DiXiaoNie
 * @date 2023/02/05
 * @since 2023/2/5 11:25
 */
@Topic(TopicConfig.VMS_VENDOUT_TOPIC)
@Slf4j
public class VendoutMsgHandler implements ACHandler<VendoutContract> {
    @Autowired
    private VendingMachineService vmService;

    @Override
    public void process(String topic, VendoutContract vendoutContract) throws Exception {
        log.info("执行出货{}", vendoutContract);
        if (Strings.isNullOrEmpty(vendoutContract.getInnerCode())) {
            return;
        }
        //处理出货逻辑
        this.vmService.vendout(vendoutContract);
    }
}
